# controller

# responsible for the presentation of the deletion question

from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

from Utilities import *

class BuildDeleteAllKeysQuestion(webapp.RequestHandler):
    def post(self):
        utilities = Utilities()
        
        # get some necessary infos
        userText = utilities.getUserText()
        username = utilities.getUsername()
        
        if username:
            urlText = utilities.getUrlTextLogout()
            url = utilities.getLogout(self)
             
            # set the hint-text and hint-color
#            hintText = _('Warning - this action can not be undone!')
            hintText = 'Warning - this action can not be undone!'
            hintColor = 'red'
            
            # menu-text
            credentialsText = utilities.getMenuTextCredentials()
            yourDataText = utilities.getMenuTextYourData()
            infoText = utilities.getMenuTextInfo()
            
            # get data for some place-holder
            title = utilities.getTitleText()        
            headline = self.buildHeadline()
            buttons = self.buildButtons()
    
            finalTemplateValues = {
                                   'title': title,
                                   'userText': userText,
                                   'user': username,
                                   'url': url,
                                   'urlText': urlText,
                                   'hintText': hintText,
                                   'hintColor': hintColor,
                                   'credentials': credentialsText,
                                   'yourData': yourDataText,
                                   'info': infoText,
                                   'headline': headline,
                                   'buttons': buttons
                                   }
            
            html = template.render('view/templates/deleteallkeys.html', finalTemplateValues)
            
            self.response.out.write(html)
        else:
            self.redirect('/')
        
    def buildHeadline(self):
#        headline = _('Do your really want to delete all keys inside your storage-services?')
        headline = 'Do your really want to delete all keys inside your storage-services?'
        return headline
    
    def buildButtons(self):
        buttons = ''
        buttons = buttons + '<p></p>'
        buttons = buttons + '<table>'
        buttons = buttons + '<tr>' 
        buttons = buttons + '<td align="right">' 
        buttons = buttons + '<form action="/deleteallbucketkeyssure" method="get" accept-charset="utf-8">'
        buttons = buttons + '<input type="submit" value="'
#        buttons = buttons + _('Yes, delete them all')
        buttons = buttons + 'Yes, delete them all'
        buttons = buttons + '">'
        buttons = buttons + '</form>'
        buttons = buttons + '</td>'
        buttons = buttons + '<td align="right">'                       
        buttons = buttons + '<form action="/selectdata" method="get" accept-charset="utf-8">'
        buttons = buttons + '<input type="submit" value="'
#        buttons = buttons + _('No, do not delete them')
        buttons = buttons + 'No, do not delete them'
        buttons = buttons + '">'               
        buttons = buttons + '</form>'
        buttons = buttons + '</td>'        
        buttons = buttons + '</tr>'        
        buttons = buttons + '</table>'
        
        return buttons
        
        